<?php

namespace App\Http\ViewComposers;

use App\Http\Controllers\Home\Cart\Api\CartApi;
use Illuminate\View\View;
use App\Http\Controllers\Home\Index\Api\IndexApi;
                    
class IndexComposer
{
    
    protected $index;
    
    public function __construct(IndexApi $index)
    {
         $this->index = $index;

    }
            
    /**
     * 绑定数据到视图.
     *
     * @param View $view
     * @return void
     */
    
    public function compose(View $view)
    {   

        $view->with('sortList', $this->index->loadSort() );
        $view->with('carousels', $this->index->loadCarousels() );
        $view->with('asidePromotion', $this->index->loadAsidePromotion() );
        $view->with('homePromotion', $this->index->loadHomePromotion(3, 2) );
        $view->with('hotSale', $this->index->loadHotSale() );
        $view->with('friendLink', $this->index->loadFriendLink() );
        $view->with('company', $this->index->loadCompany() );
        
    }
}